package com.tarena.dang.actions.main;

import java.util.List;

import com.tarena.dang.pojos.Book;
import com.tarena.dang.pojos.Category;
import com.tarena.dang.services.ProductService;
import com.tarena.dang.services.impl.ProductServiceImpl;

public class ProductAction {
	private int pid;
	private Book book;
	private List<Category> bookCats;
	public String execute() {
		ProductService service = new ProductServiceImpl();
		try {
			bookCats=service.findBookCatsById(pid);
			book=service.findBook(bookCats);
			return "success";
		} catch (Exception e) {
			e.printStackTrace();
			return "fail";
		}

		// Class c=null;
		// try {
		// c = Class.forName(book);
		// Object obj = c.getInterfaces();
		// Book b = (Book) obj;
		// System.out.println(b.getAuthor());
		// return "success";
		// } catch (ClassNotFoundException e) {
		// e.printStackTrace();
		// return "fail";
		// }
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public int getPid() {
		return pid;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public Book getBook() {
		return book;
	}

	public void setBookCats(List<Category> bookCats) {
		this.bookCats = bookCats;
	}

	public List<Category> getBookCats() {
		return bookCats;
	}

}
